package _interview150;

import java.util.Arrays;

/**
 * 452. 用最少数量的箭引爆气球
 */
public class No452 {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points, ((o1, o2) -> o1[0] != o2[0] ? (o1[0] < o2[0] ? -1 : 1) : (o1[1] < o2[1] ? -1 : 1)));
        int ans = 1;
        int curNum = points[points.length - 1][0];
        for (int i = points.length - 2; i >= 0; i--) {
            if (points[i][1] < curNum) {
                ans++;
                curNum = points[i][0];
            }
        }
        return ans;
    }
}